home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / TexBindX.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  5.3 KB  |  176 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38.  
  39. #ifdef MULTIIMAGE
  40.   #define TEX_OBJ *objPtr++
  41.   #define LIST_NUM listNum++
  42. #else
  43.   #define TEX_OBJ obj
  44.   #define LIST_NUM list
  45. #endif
  46.  
  47. /* Define calls if using function pointers or not */
  48. #ifdef FUNCTION_PTRS
  49.   #if (TEX_SRC == DISPLAY_LIST)
  50.     #define TEXBIND_CALL   (*calllist)(LIST_NUM);
  51.   #else
  52.     #define TEXBIND_CALL   (*bindtexture)(target, TEX_OBJ);
  53.   #endif
  54.   #if defined(TRI_DRAW)
  55.     #define VERTEX_CALL  \
  56.       (*texcoord4fv)(point); \
  57.       (*vertex3fv)(point+4); \
  58.       (*texcoord4fv)(point+7); \
  59.       (*vertex3fv)(point+11); \
  60.       (*texcoord4fv)(point+14); \
  61.       (*vertex3fv)(point+18);
  62.     #define BEGIN_CALL   (*begin)(GL_TRIANGLE_STRIP);
  63.     #define END_CALL     (*end)();
  64.   #elif defined(POINT_DRAW)
  65.     #define VERTEX_CALL  \
  66.       (*texcoord4fv)(point); \
  67.       (*vertex3fv)(point+4);
  68.     #define BEGIN_CALL   (*begin)(GL_POINTS);
  69.     #define END_CALL     (*end)();
  70.   #endif
  71. #else
  72.   #if (TEX_SRC == DISPLAY_LIST)
  73.     #define TEXBIND_CALL   glCallList(LIST_NUM);
  74.   #else
  75.     #define TEXBIND_CALL   glBindTextureEXT(target, TEX_OBJ);
  76.   #endif
  77.   #if defined(TRI_DRAW)
  78.     #define VERTEX_CALL  \
  79.       glTexCoord4fv(point); \
  80.       glVertex3fv(point+4); \
  81.       glTexCoord4fv(point+7); \
  82.       glVertex3fv(point+11); \
  83.       glTexCoord4fv(point+14); \
  84.       glVertex3fv(point+18);
  85.     #define BEGIN_CALL   glBegin(GL_TRIANGLE_STRIP);
  86.     #define END_CALL     glEnd();
  87.   #elif defined(POINT_DRAW)
  88.     #define VERTEX_CALL  \
  89.       glTexCoord4fv(point); \
  90.       glVertex3fv(point+4);
  91.     #define BEGIN_CALL   glBegin(GL_POINTS);
  92.     #define END_CALL     glEnd();
  93.   #endif
  94. #endif
  95.  
  96. #if defined(POINT_DRAW) || defined(TRI_DRAW)
  97.   #define DEFINE_TRI GLfloat* point = this->triangleData; 
  98.   #define TEXBIND  { \
  99.     TEXBIND_CALL \
  100.     BEGIN_CALL   \
  101.     VERTEX_CALL  \
  102.     END_CALL \
  103.   }
  104. #else
  105.   #define DEFINE_TRI
  106.   #define TEXBIND  \
  107.     TEXBIND_CALL
  108. #endif
  109.  
  110. void FUNCTION (TestPtr thisTest)
  111. {
  112.     TexImagePtr this = (TexImagePtr)thisTest;
  113.     int iterations = this->iterations;
  114.     GLenum target = this->texTarget;
  115.     int i;
  116.   #ifdef MULTIIMAGE
  117.     int numObjects = this->numObjects;
  118.     int j;
  119.    #if (TEX_SRC == DISPLAY_LIST)
  120.     GLuint listBase = this->dlBase;
  121.     GLuint listNum = listBase;
  122.    #else
  123.     GLuint *objData = this->texObjs;
  124.     GLuint *objPtr = objData;
  125.    #endif
  126.   #else
  127.    #if (TEX_SRC == DISPLAY_LIST)
  128.     GLuint list = this->dlBase;
  129.    #else
  130.     GLuint obj = *(this->texObjs);
  131.    #endif
  132.   #endif
  133.   #ifdef FUNCTION_PTRS
  134.    #ifdef WIN32
  135.     #define LINK_CONV APIENTRY
  136.    #else
  137.     #define LINK_CONV
  138.    #endif
  139.    #if (TEX_SRC == DISPLAY_LIST)
  140.     void (LINK_CONV *calllist)(GLuint) = glCallList;
  141.    #else
  142.     void (LINK_CONV *bindtexture)(GLenum, GLuint) = glBindTextureEXT;
  143.    #endif
  144.    #if defined(POINT_DRAW) || defined(TRI_DRAW)
  145.     void (LINK_CONV *texcoord4fv)(const GLfloat*) = glTexCoord4fv;
  146.     void (LINK_CONV *vertex3fv)(const GLfloat*) = glVertex3fv;
  147.     void (LINK_CONV *begin)(GLenum) = glBegin;
  148.     void (LINK_CONV *end)(void) = glEnd;
  149.    #endif
  150.   #endif
  151.     DEFINE_TRI
  152.  
  153.     for (i = iterations; i > 0; i--) {
  154.         #ifdef MULTIIMAGE
  155.       for (j = numObjects; j > 0; j--)
  156.         #endif
  157.         TEXBIND
  158.         #ifdef MULTIIMAGE
  159.      #if (TEX_SRC == DISPLAY_LIST)
  160.       listNum = listBase;
  161.      #else
  162.       objPtr = objData;
  163.      #endif
  164.         #endif
  165.     }
  166. }
  167.  
  168. #undef TEXBIND_CALL
  169. #undef TEXBIND
  170. #undef TEX_OBJ
  171. #undef LIST_NUM
  172. #undef BEGIN_CALL
  173. #undef END_CALL
  174. #undef VERTEX_CALL
  175. #undef DEFINE_TRI
  176.